using System;
using System.Collections.Generic;
using Mussel.Addins;
using Natrue.Data;
using NHibernate.Expression;

namespace Natrue
{
    [MusselType("IAttachmentManager")]
    public interface IAttachmentManager
    {
        void SaveAttachment(Attachment info);
        void DeleteAttachment(Guid attachmentKey);
        Attachment GetAttachmentDetail(Guid attachmentKey);
        IList<Attachment> SearchAttachmentList(params ICriterion[] criterions);
    }

    [MusselType("AttachmentManager")]
    public class AttachmentManager : DOPAddinItem, IAttachmentManager
    {
        #region Implementation of IAttachmentManager

        public void SaveAttachment(Attachment info)
        {
            ARHelper.CreateIBO(info);
        }

        public void DeleteAttachment(Guid attachmentKey)
        {
            ARHelper.DeleteIBO<Attachment>(attachmentKey);
        }

        public Attachment GetAttachmentDetail(Guid attachmentKey)
        {
            return ARHelper.GetIBODetail<Attachment>(attachmentKey);
        }

        public IList<Attachment> SearchAttachmentList(params ICriterion[] criterions)
        {
            return ARHelper.GetIBOList<Attachment>(criterions);
        }

        #endregion
    }
}